﻿using UnityEngine;
using System.Collections;

public class PointMatrix : MonoBehaviour {
	public int vWidth = 256;
	public int vHeight = 144;
	public Material mat;

	// Use this for initialization
	void Start () {
		init();
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void init(){
		for(int i=0;i<vWidth;++i){
			for(int j=vHeight;j>0;--j){
				GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Quad);
				obj.name = string.Format("v_{0:000}_{1:000}",i,(vHeight - j));
				obj.transform.SetParent(gameObject.transform);
				obj.layer = gameObject.layer;
				obj.transform.localPosition = new Vector3(i,j-1,0);
				obj.transform.localScale = new Vector3(1,1,1);
				Material tm = Instantiate(mat);
				obj.GetComponent<Renderer>().material = tm;
				tm.SetFloat("_Width",vWidth);
				tm.SetFloat("_Height",vHeight);
				tm.SetFloat("_X",i);
				tm.SetFloat("_Y",j-1);
			}
		}
	}
}
